package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import clienteWeb.ControladorWeb;

public class Comanda extends HttpServlet{

	public Comanda(){}
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
	    response.setContentType("text/html");
	    PrintWriter out = response.getWriter();
	    String title = "Liberar de Mesa";
	    
	    ControladorWeb.getInstancia().crearComanda(Integer.valueOf(request.getParameter("cbMesas")));
	    
	    String html = "<%@ page language=\"java\" contentType=\"text/html; charset=ISO-8859-1\"" +
	    		"pageEncoding=\"ISO-8859-1\"%>" +
	    		"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" +
	    		"<html>" +
	    		"<head>" +
	    		"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">" +
	    		"<title>Insert title here</title>" +
	    		"<script type=\"text/javascript\">" +
	    		"\u0009function validarForm(){" +
	    		"\u0009\u0009document.getElementById(\"formulario\").submit();" +
	    		"\u0009}" +
	    		"</script>" +
	    		"</head><body>" +
	    		"<div>" +
	    		"\u0009\u0009<h2>Liberar Mesa</h2>" +
	    		"</div>" +
	    		"<form name=\"frmAgregarItemComanda\" id=\"formulario\" method=\"GET\" action=\"AgregarItemComanda\">" +
	    		"\u0009 <table border=\"0\"> " +
	    		"<tr>" +
	    		"<td> " +
	    		"Codigo de producto  " +
	    		"     </td> " +
	    		"     <td> " +
	    		"<td><input type=\"text\" id=\"txtIdProducto\" name=\"txtIdProducto\" value=\"\" class=\"textbox \" style=\"width: 30px; \"> " +
	    		"     </td>  " +
	    		"     <td> " +
	    		"      Cantidad " +
	    		"     </td> " +
	    		"     <td><input type=\"text\" id=\"txtCantidad\" name=\"txtCantidad\" value=\"\" class=\"textbox txtUser\" style=\"width: 30px; \"> " +
	    		"      </td>      " +
	    		"     <td/>" +
	    		"     </tr> " +
	    		"   </table>" +
	    		"        <blockquote>" +
	    		"          \u0009<p>" +
	    		"       \u0009        <input name=\"btnAgregarItemComanda\" type=\"button\" value=\"Agregar Item\" onClick=\"validarForm();\"> " +
	    		"       \u0009  </p>" +
	    		"      </blockquote>" +
	    		"</form>" +
	    		"</body>" +
	    		"</html>";
	    out.println(html);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	doGet(request, response);
}


}
